from flask import Blueprint
from flask import redirect
from flask import request
from flask import session

admin_blue = Blueprint("admin",__name__,url_prefix="/admin")

from . import views

@admin_blue.before_request
def check_admin():
    #判断当前登陆后台的用户是否是管理员
    #None表示默认值
    is_admin = session.get("is_admin",None)
    if not is_admin and not request.url.endswith("/admin/login"):
        return redirect("/")